<?php
    jimport( 'joomla.application.component.view');
    class NormalViewFiledetail extends JView
    {
		function display($tpl = null)
		{
			$model = $this->getModel('normal'); //get default model
			
			// list all locations, timespans and industries
			$this->assignRef( 'locations', $model->getLocations() );
			$this->assignRef( 'timespans', $model->getTimespans() );
			$this->assignRef( 'industries', $model->getIndustries() );
			
			//get POST/GET parameters' value
			$fileId = JRequest::getVar('fileId');
			if($fileId)
			{
				$file = $model->getFile($fileId);
				
				$this->assign( 'file', $file);
				
				$app = JFactory::getApplication();
				$data = $app->getUserState('normal.filedetail.form.data');
				
				// var_dump($data);
				$this->assign( 'linkToFile', $data['linkToFile']);
				
				$this->assign( 'location', $model->getLocationName($file->location_id));
				$this->assign( 'timespan', $model->getTimespanName($file->timespan_id));
				$this->assign( 'industry', $model->getIndustryName($file->industry_id));
				$this->assign( 'keywords', $model->getFileKeywords($fileId));
				$this->assign( 'showAcknowledgement', JRequest::getVar('content') == 'acknowledgement');				
			}
			
			parent::display($tpl); //display defaul template
		}
    }